{extend name='extra@admin/content'}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <button data-modal='{:url("$classuri/add_category")}' data-title="添加分类" class='layui-btn layui-btn-small'>
        <i class='fa fa-plus'></i> 添加分类
    </button>
    <button data-update data-field='delete' data-action='{:url("$classuri/del_category")}' class='layui-btn layui-btn-small layui-btn-danger'>
        <i class='fa fa-remove'></i> 删除分类
    </button>
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="__SELF__" onsubmit="return false" method="get">
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">分类名称</label>
        <div class="layui-input-inline">
            <input name="title" value="{$Think.get.title|default=''}" placeholder="请输入分类名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
    </div>
</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="true" method="post">
    {if empty($list)}
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    {else}
    <input type="hidden" value="resort" name="action"/>
    <table class="layui-table" lay-skin="line" lay-size="sm">
        <thead>
            <tr>
                <th class='list-table-check-td'>
                    <input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
                </th>
                <th class='text-left nowrap'>ID</th>
                <th class='text-left nowrap'>分类名称</th>
                <th class='text-left nowrap'>logo</th>
                <th class='text-left nowrap'>扩展分类</th>
                <th class='text-left nowrap'>推荐</th>
                <th class='text-left nowrap'>状态</th>
                <th class='text-left nowrap'>排序</th>
                <th class='text-left nowrap'>添加时间</th>
                <th class='text-left nowrap'>操作</th>
            </tr>
        </thead>
        <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td>
                    <input class="list-check-box" value='{$vo.id}' type='checkbox'/>
                  <!--<input name="dis_order" data-id="{$vo.id}" value="{$vo.dis_order}"/>-->
                </td>
                <td class='text-left nowrap'>
                    {$vo.id}
                </td>
                <td class='text-left nowrap'>
                    {$vo.title}
                </td>
                <td class='text-left nowrap'>
                    <img src="{$vo.logo}" width="80px;" height="80px;">
                </td>
                <td class='text-left nowrap'>
                    {if condition="$vo.is_exp eq 1"}
                        是
                    {else /}
                        否
                    {/if}
                </td>
                <td class='text-left nowrap'>
                    {if condition="!empty($vo.is_recommend)"}
                        <span class="text-explode">|</span>
                        {if condition="$vo.is_recommend eq 1"}
                            推荐位一
                        {else }
                            推荐位二
                        {/if}
                        {if auth("$classuri/set_recommend_category")}
                        <span class="text-explode">|</span>
                        <a data-modal='{:url("$classuri/set_recommend")}?id={$vo.id}' href="javascript:void(0)">设置</a>
                        {/if}
                    {else /}
                        <span class="text-explode">|</span>
                        暂未设置
                        {if auth("$classuri/set_recommend_category")}
                            <span class="text-explode">|</span>
                            <a data-modal='{:url("$classuri/set_recommend")}?id={$vo.id}' href="javascript:void(0)">设置</a>
                        {/if}
                    {/if}
                    <!--{if $vo.is_recommend eq 0}-->
                    <!--<a data-update="{$vo.id}" data-field='is_recommend' data-value='1' data-action='{:url("$classuri/set_recommend")}'-->
                    <!--href="javascript:void(0)">推荐</a>-->
                    <!--{elseif $vo.is_recommend eq 1 }-->
                    <!--<a data-update="{$vo.id}" data-field='is_recommend' data-value='0' data-action='{:url("$classuri/set_recommend")}'-->
                    <!--href="javascript:void(0)">关闭</a>-->
                    <!--{/if}-->
                </td>
                <td class='text-left nowrap'>
                    {if $vo.status eq 0}
                    <a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/setCateStatus")}'
                       href="javascript:void(0)">开启</a>
                    {elseif $vo.status eq 1 }
                    <a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/setCateStatus")}'
                       href="javascript:void(0)">关闭</a>
                    {/if}
                </td>
                <td class='text-left nowrap'>
                    <input type="text" data-id="{$vo.id}" name="dis_order" value="{$vo.dis_order}" onblur="save(this);">
                </td>
                <td class='text-left nowrap'>
                    {$vo.addtime|date="Y-m-d",###}
                </td>
                <td class='text-left nowrap'>
                    {if auth("$classuri/add_category")}
                    <span class="text-explode">|</span>
                    <a data-modal='{:url("$classuri/add_category")}?id={$vo.id}' href="javascript:void(0)">编辑</a>
                    {/if}
                    {if condition="$vo.is_recommend gt 0"}
                        {if auth("$classuri/add_category")}
                            <span class="text-explode">|</span>
                            <a data-open='{:url("$classuri/set_recommend_goods")}?id={$vo.id}' href="javascript:void(0)">推荐商品</a>
                        {/if}
                    {/if}
                    <!--{if auth("$classuri/child_category")}-->
                    <!--<span class="text-explode">|</span>-->
                    <!--<a data-modal='{:url("$classuri/child_category")}?id={$vo.id}' href="javascript:void(0)">下级分类</a>-->
                    <!--{/if}-->
                    <!-- {if $vo.status eq 1 and auth("$classuri/store_forbid")}
                    <span class="text-explode">|</span>
                    <a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/store_forbid")}'
                       href="javascript:void(0)">禁用</a>
                    {elseif auth("$classuri/store_start")}
                    <span class="text-explode">|</span>
                    <a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/store_start")}'
                       href="javascript:void(0)">启用</a>
                    {/if} -->
                    {if auth("$classuri/del_category")}
                    <span class="text-explode">|</span>
                    <a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del_category")}'
                       href="javascript:void(0)">删除</a>
                    {/if}
                    
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
    {if isset($page)}<p>{$page}</p>{/if}

    {/if}
    <script>
        window.laydate.render({range: true, elem: '#range-date', format: 'yyyy/MM/dd'});
        /**
         *  保存分类排序功能
         */
        function save(obj){
            var id = $(obj).attr('data-id');
            var dis_order = $(obj).val();
            $.post("{:url('Goodscategory/changeCateDis0rder')}",
                {id:id,dis_order:dis_order},
                function(data){
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
//                $("#sub").removeAttr("disabled");
                    });
                }
            );
        }
    </script>
</form>
{/block}